package org.mine.design.proxy.controller;

import org.mine.design.proxy.factory.MineCglibProxyFactory;
import org.mine.design.proxy.factory.MineJdkProxyFactory;
import org.mine.design.proxy.service.SmsService;
import org.mine.design.proxy.service.impl.SmsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProxyController {

    @Autowired
    private SmsService smsService;


    @RequestMapping("/proxy/test")
    public void test() {
        //jdk代理
        SmsService jdkService = (SmsService) MineJdkProxyFactory.getProxy(smsService);
        jdkService.send("哈哈哈");

        //CGLIB代理
        SmsService cglibService = (SmsService) MineCglibProxyFactory.getProxy(SmsServiceImpl.class);
        cglibService.send("哈哈哈");

        //接口default
        smsService.proxy("哈哈哈");
    }


}
